import request from "@/utils/request"
import { GoodDetailInfo,Livelys } from './interface'
enum Api {
    goodDetailInfoApi = '/xhr/item/detailForSpec.json',
    LikesApi = '/xhr/item/rcmd.json',
    hotGoodListApi = '/xhr/item/hotsellItem.json',
    livelysApi='/xhr/topic/getListByParam.json'
}
/**
 * @__timestamp  时间戳
*/

/**
 * 获取商品详情
 * @param id 商品id
 * @returns GoodDetailInfo
 */
export const reqGoodDetailInfo = (id: number) => {
    return request.get<GoodDetailInfo, any>(Api.goodDetailInfoApi, {
        params: {
            __timestamp: window.Date.now(),
            id
        }
    })
}

/**
 * 获取猜你喜欢商品列表
 * @param id 商品id
 * @returns GoodDetailInfo[]
 */
 export const reqLikes = (itemId: number) => {
    return request.get<GoodDetailInfo[], any>(Api.LikesApi, {
        params: {
            __timestamp: window.Date.now(),
            itemId
        }
    })
}

/**
 * 获取热卖商品列表
 * @returns GoodDetailInfo[]
 */
 export const reqHotGoodList = (data:FormData) => {
    return request.post<GoodDetailInfo[], any>(Api.hotGoodListApi,data)
}

/**
 * 获取专题推荐商品列表
 * @returns Livelys[]
 */
 export const reqLivelys = (data:FormData) => {
    return request.post<Livelys[], any>(Api.livelysApi,data)
}